package com.candy.control;

import com.candy.service.UserInfoManagerService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/updateUserInfo")
public class UserInfoUpdateServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //        设置字符集，处理中文乱码问题
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        //        调用业务逻辑处理层
        UserInfoManagerService usermanager=new UserInfoManagerService();
        usermanager.updateUserInfo(req.getParameter("username"),
                req.getParameter("userpwd"),
                req.getParameter("useraddress"),
                req.getParameter("usertel"),
                Integer.parseInt(req.getParameter("id")));
//        新增成功后，跳转至查询页面查看结果
        req.getRequestDispatcher("WEB-INF/userManager/userInfo.jsp").forward(req,resp);


    }
}
